# -*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, url
from django.views.generic.simple import direct_to_template

from dbsupply.models import *

urlpatterns = patterns('dbsupply.views',
    url(r'^$', direct_to_template, {'template':'dbsupply_main.html'}),
    url(r'^lemma/$', direct_to_template, {'template': 'items_list.html', 
                                          'extra_context':{
                                                           'header': u'Редактировать леммы',
                                                           'items': lambda: Lemma.objects.all().order_by('-created')[:20],
                                                           'model': 'lemma'}
                                          }),
    url(r'^pos/$', direct_to_template, {'template': 'items_list.html',
                                        'extra_context':{
                                            'header': u'Редактировать словоформы',
                                            'items': lambda: POSCommon.objects.all()[:20],
                                            'model': 'pos'}
                                        }),
    url(r'^lemma/(?P<id>\d+)/(?P<action>\w+)/$', 'lemma_item'),
    #url(r'^pos/(?P<part_of_speech>\w+)/(?P<id>\d+)/(?P<action>\w+)/$', 'part_of_speech_item'),
    url(r'^pos/(?P<id>\d+)/(?P<action>\w+)/$', 'pos_item'),
    # for ajax and cool features
    url(r'^(?P<model>\w+)/ajax/(?P<verified>\w+)/$', 'items_ajax_verified'),
    url(r'^(?P<model>\w+)/ajax/(?P<id>\d+)/view/$', 'item_ajax_view'),
    url(r'^(?P<model>\w+)/ajax/(?P<id>\d+)/edit/$', 'item_ajax_edit'),
    url(r'^(?P<model>\w+)/ajax/(?P<id>\d+)/delete/$', 'item_ajax_delete'),
)